package com.book.dao;

import com.book.entity.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @Author zzw2000
 * @Date 2022年08月10日 20:31
 * @Description 描述
 */
public interface AdminMapper {

    @Select("SELECT * FROM admin WHERE username=#{username} AND password=#{password}")
    Admin getAdmin(@Param("username") String username, @Param("password") String password);

    @Insert("INSERT INTO admin (username, nickname, password) VALUES (#{username},#{nickname},#{password})")
    int register(@Param("username") String username, @Param("nickname") String nickname, @Param("password") String password);

    @Select("SELECT * FROM admin WHERE username=#{username}")
    Admin getOne(String username);

    @Update("UPDATE admin set nickname=#{nickname},password=#{password} WHERE id=#{id}")
    int updateInfo(@Param("id") int id, @Param("nickname") String nickname, @Param("password") String password);
}
